#例10.12打开一个文件并写入”Hello World”，需做异常处理
filename = 'my_file.txt'
mode = 'w'
writer = open(filename, mode)
try:
    writer.write('Hello ')
    writer.write('World')
finally:
    writer.close()
